package com.xiyu.service.controller.admin.elder;
import com.xiyu.service.vo.elder.tryLiving.TryLivingGetOutput;
import com.xiyu.service.vo.elder.tryLiving.TryLivingQueryOutput;
import com.xiyu.service.vo.elder.tryLiving.TryLivingQueryInput;
import com.xiyu.service.vo.elder.tryLiving.TryLivingUpdateInput;
import com.xiyu.service.vo.elder.tryLiving.TryLivingCreateInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.elder.TryLivingService;

@Tag(name = "试住登记")
@RestController
@RequestMapping("/elder/try-living")
@Validated
public class TryLivingController {

    @Resource
    private TryLivingService tryLivingService;

    @PostMapping("/create")
    @Operation(summary = "创建试住登记")
    @PreAuthorize("@ss.hasPermission('	 elder:try-living:query')")
    public CommonResult<Long> create(@Valid @RequestBody TryLivingCreateInput inputVO) {
        return success(tryLivingService.create(inputVO));
    }

    @PostMapping("/update")
    @Operation(summary = "更新试住登记")
    @PreAuthorize("@ss.hasPermission('elder:try-living:update')")
    public CommonResult<Boolean> update(@Valid @RequestBody TryLivingUpdateInput inputVO) {
        return success(tryLivingService.update(inputVO));
    }

    @GetMapping("/query")
    @Operation(summary = "试住登记查询")
    @PreAuthorize("@ss.hasPermission('elder:try-living:query')")
    public CommonResult<PageResult<TryLivingQueryOutput>> query(@Valid TryLivingQueryInput inputVO) {
        return success(tryLivingService.query(inputVO));
    }

    @DeleteMapping("/deleted")
    @Operation(summary = "删除试住登记")
    @PreAuthorize("@ss.hasPermission('elder:try-living:deleted')")
    @Parameter(name = "id", description = "试住登记ID", example = "")
    public CommonResult<Boolean> deleted(@RequestParam("id") Long id) {
        return success(tryLivingService.deleted(id));
    }

    @GetMapping("/get")
    @Operation(summary = "获取单个试住登记信息")
    @Parameter(name = "id", description = "试住登记ID", example = "")
    public CommonResult<TryLivingGetOutput> get(@RequestParam("id") Long id) {
        return success(tryLivingService.get(id));
    }

}
